R version 4.1.1 “Kick Things”
library(readr)
library(dplyr)
library(tidyr)
library(stringr)
library(ggplot2)
library(GGally)
library(gridExtra)
library(plotly)Countries with high female freedom scores will have less than average female suicide rates
Ho: mu~suicide rates lo female freedom~ >= average female suicide rate
Ha: mu~suicide rates hi female freedom~ < average female suicide rate
pf_ss_women_fgm - Female genital mutilationpf_ss_women_missing - ??pf_ss_women_inheritance_widows - Equal inheritance rights for widowspf_ss_women_inheritance_daughters - Equal inheritance rights for daughterspf_movement_women - Freedom of movement for womenpf_identity_sex_female - Female to female relationshipspf_identity_divorce - DivorceCountries with smaller populations will have more freedom
Ho: mu~freedom_small_population - mu~freedom_large_population <= 0
Ha: mu~freedom_small_population - mu~freedom_large_population > 0
hfi_score - Overall Human Freedom Index scorepopulation - (suicides dataset) country populationThere are many, many columns in this dataset, so let us focus on a few columns * 3 categorical variables + country + ISO_code (country abbreviation) + region * 119 numeric (subset focus) + Freedom indicators and their aggregate category scores, like - Female genital mutilation and inheritance rights (widows, daughters) make up 3 columns and are aggregated into one category score Women’’s security and safety * 1 time-series + year
## spec_tbl_df [1,458 × 123] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
## $ year : num [1:1458] 2016 2016 2016 2016 2016 ...
## $ ISO_code : chr [1:1458] "ALB" "DZA" "AGO" "ARG" ...
## $ countries : chr [1:1458] "Albania" "Algeria" "Angola" "Argentina" ...
## $ region : chr [1:1458] "Eastern Europe" "Middle East & North Africa" "Sub-Saharan Africa" "Latin America & the Caribbean" ...
## $ pf_rol_procedural : num [1:1458] 6.66 NA NA 7.1 NA ...
## $ pf_rol_civil : num [1:1458] 4.55 NA NA 5.79 NA ...
## $ pf_rol_criminal : num [1:1458] 4.67 NA NA 4.34 NA ...
## $ pf_rol : num [1:1458] 5.29 3.82 3.45 5.74 5 ...
## $ pf_ss_homicide : num [1:1458] 8.92 9.46 8.06 7.62 8.81 ...
## $ pf_ss_disappearances_disap : num [1:1458] 10 10 5 10 10 10 10 10 10 10 ...
## $ pf_ss_disappearances_violent : num [1:1458] 10 9.29 10 10 10 ...
## $ pf_ss_disappearances_organized : num [1:1458] 10 5 7.5 7.5 7.5 10 10 7.5 NA 2.5 ...
## $ pf_ss_disappearances_fatalities : num [1:1458] 10 9.93 10 10 9.32 ...
## $ pf_ss_disappearances_injuries : num [1:1458] 10 9.99 10 9.99 9.93 ...
## $ pf_ss_disappearances : num [1:1458] 10 8.84 8.5 9.5 9.35 ...
## $ pf_ss_women_fgm : num [1:1458] 10 10 10 10 10 10 10 10 NA 10 ...
## $ pf_ss_women_missing : num [1:1458] 7.5 7.5 10 10 5 10 10 7.5 NA 7.5 ...
## $ pf_ss_women_inheritance_widows : num [1:1458] 5 0 5 10 10 10 10 5 NA 0 ...
## $ pf_ss_women_inheritance_daughters : num [1:1458] 5 0 5 10 10 10 10 10 NA 0 ...
## $ pf_ss_women_inheritance : num [1:1458] 5 0 5 10 10 10 10 7.5 NA 0 ...
## $ pf_ss_women : num [1:1458] 7.5 5.83 8.33 10 8.33 ...
## $ pf_ss : num [1:1458] 8.81 8.04 8.3 9.04 8.83 ...
## $ pf_movement_domestic : num [1:1458] 5 5 0 10 5 10 10 5 10 10 ...
## $ pf_movement_foreign : num [1:1458] 10 5 5 10 5 10 10 5 10 5 ...
## $ pf_movement_women : num [1:1458] 5 5 10 10 10 10 10 5 NA 5 ...
## $ pf_movement : num [1:1458] 6.67 5 5 10 6.67 ...
## $ pf_religion_estop_establish : num [1:1458] NA NA NA NA NA NA NA NA NA NA ...
## $ pf_religion_estop_operate : num [1:1458] NA NA NA NA NA NA NA NA NA NA ...
## $ pf_religion_estop : num [1:1458] 10 5 10 7.5 5 10 10 2.5 NA 10 ...
## $ pf_religion_harassment : num [1:1458] 9.57 6.87 8.9 9.04 8.58 ...
## $ pf_religion_restrictions : num [1:1458] 8.01 2.96 7.46 6.85 5.09 ...
## $ pf_religion : num [1:1458] 9.19 4.94 8.79 7.8 6.22 ...
## $ pf_association_association : num [1:1458] 10 5 2.5 7.5 7.5 10 10 2.5 NA 5 ...
## $ pf_association_assembly : num [1:1458] 10 5 2.5 10 7.5 10 10 5 NA 0 ...
## $ pf_association_political_establish: num [1:1458] NA NA NA NA NA NA NA NA NA NA ...
## $ pf_association_political_operate : num [1:1458] NA NA NA NA NA NA NA NA NA NA ...
## $ pf_association_political : num [1:1458] 10 5 2.5 5 5 10 10 2.5 NA 0 ...
## $ pf_association_prof_establish : num [1:1458] NA NA NA NA NA NA NA NA NA NA ...
## $ pf_association_prof_operate : num [1:1458] NA NA NA NA NA NA NA NA NA NA ...
## $ pf_association_prof : num [1:1458] 10 5 5 7.5 5 10 10 2.5 NA 10 ...
## $ pf_association_sport_establish : num [1:1458] NA NA NA NA NA NA NA NA NA NA ...
## $ pf_association_sport_operate : num [1:1458] NA NA NA NA NA NA NA NA NA NA ...
## $ pf_association_sport : num [1:1458] 10 5 7.5 7.5 7.5 10 10 2.5 NA 10 ...
## $ pf_association : num [1:1458] 10 5 4 7.5 6.5 10 10 3 NA 5 ...
## $ pf_expression_killed : num [1:1458] 10 10 10 10 10 10 10 10 10 10 ...
## $ pf_expression_jailed : num [1:1458] 10 10 10 10 10 ...
## $ pf_expression_influence : num [1:1458] 5 2.67 2.67 5.67 3.33 ...
## $ pf_expression_control : num [1:1458] 5.25 4 2.5 5.5 4.25 7.75 8 0.25 7.25 0.75 ...
## $ pf_expression_cable : num [1:1458] 10 10 7.5 10 7.5 10 10 10 NA 7.5 ...
## $ pf_expression_newspapers : num [1:1458] 10 7.5 5 10 7.5 10 10 0 NA 7.5 ...
## $ pf_expression_internet : num [1:1458] 10 7.5 7.5 10 7.5 10 10 7.5 NA 2.5 ...
## $ pf_expression : num [1:1458] 8.61 7.38 6.45 8.74 7.15 ...
## $ pf_identity_legal : num [1:1458] 0 NA 10 10 7 7 10 0 NA NA ...
## $ pf_identity_parental_marriage : num [1:1458] 10 0 10 10 10 10 10 10 10 0 ...
## $ pf_identity_parental_divorce : num [1:1458] 10 5 10 10 10 10 10 10 10 0 ...
## $ pf_identity_parental : num [1:1458] 10 2.5 10 10 10 10 10 10 10 0 ...
## $ pf_identity_sex_male : num [1:1458] 10 0 0 10 10 10 10 10 10 10 ...
## $ pf_identity_sex_female : num [1:1458] 10 0 0 10 10 10 10 10 10 10 ...
## $ pf_identity_sex : num [1:1458] 10 0 0 10 10 10 10 10 10 10 ...
## $ pf_identity_divorce : num [1:1458] 5 0 10 10 5 10 10 5 NA 0 ...
## $ pf_identity : num [1:1458] 6.25 0.833 7.5 10 8 ...
## $ pf_score : num [1:1458] 7.6 5.28 6.11 8.1 6.91 ...
## $ pf_rank : num [1:1458] 57 147 117 42 84 11 8 131 64 114 ...
## $ ef_government_consumption : num [1:1458] 8.23 2.15 7.6 5.34 7.26 ...
## $ ef_government_transfers : num [1:1458] 7.51 7.82 8.89 6.05 7.75 ...
## $ ef_government_enterprises : num [1:1458] 8 0 0 6 8 10 10 0 7 10 ...
## $ ef_government_tax_income : num [1:1458] 9 7 10 7 5 5 4 9 10 10 ...
## $ ef_government_tax_payroll : num [1:1458] 7 2 9 1 5 5 3 4 10 10 ...
## $ ef_government_tax : num [1:1458] 8 4.5 9.5 4 5 5 3.5 6.5 10 10 ...
## $ ef_government : num [1:1458] 7.94 3.62 6.5 5.35 7 ...
## $ ef_legal_judicial : num [1:1458] 2.67 4.19 1.84 3.69 3.87 ...
## $ ef_legal_courts : num [1:1458] 3.15 4.33 1.97 2.93 4.2 ...
## $ ef_legal_protection : num [1:1458] 4.51 4.69 2.51 4.26 5.66 ...
## $ ef_legal_military : num [1:1458] 8.33 4.17 3.33 7.5 5.83 ...
## $ ef_legal_integrity : num [1:1458] 4.17 5 4.17 3.33 5 ...
## $ ef_legal_enforcement : num [1:1458] 4.39 4.51 2.3 3.63 5.2 ...
## $ ef_legal_restrictions : num [1:1458] 6.49 6.63 5.46 6.86 9.8 ...
## $ ef_legal_police : num [1:1458] 6.93 6.14 3.02 3.39 5.71 ...
## $ ef_legal_crime : num [1:1458] 6.22 6.74 4.29 4.13 7.01 ...
## $ ef_legal_gender : num [1:1458] 0.949 0.821 0.846 0.769 1 ...
## $ ef_legal : num [1:1458] 5.07 4.69 2.96 3.9 5.81 ...
## $ ef_money_growth : num [1:1458] 8.99 6.96 9.39 5.23 9.08 ...
## $ ef_money_sd : num [1:1458] 9.48 8.34 4.99 5.22 9.26 ...
## $ ef_money_inflation : num [1:1458] 9.74 8.72 3.05 2 9.75 ...
## $ ef_money_currency : num [1:1458] 10 5 5 10 10 10 10 5 0 10 ...
## $ ef_money : num [1:1458] 9.55 7.25 5.61 5.61 9.52 ...
## $ ef_trade_tariffs_revenue : num [1:1458] 9.63 8.48 8.99 6.06 8.87 ...
## $ ef_trade_tariffs_mean : num [1:1458] 9.24 6.22 7.72 7.26 8.76 9.5 8.96 8.2 3.36 9.06 ...
## $ ef_trade_tariffs_sd : num [1:1458] 8.02 5.92 4.25 5.94 8.02 ...
## $ ef_trade_tariffs : num [1:1458] 8.96 6.87 6.99 6.42 8.55 ...
## $ ef_trade_regulatory_nontariff : num [1:1458] 5.57 4.96 3.13 4.47 5.92 ...
## $ ef_trade_regulatory_compliance : num [1:1458] 9.405 0 0.917 5.156 8.466 ...
## $ ef_trade_regulatory : num [1:1458] 7.49 2.48 2.02 4.81 7.19 ...
## $ ef_trade_black : num [1:1458] 10 5.56 10 0 10 ...
## $ ef_trade_movement_foreign : num [1:1458] 6.31 3.66 2.95 5.36 5.11 ...
## $ ef_trade_movement_capital : num [1:1458] 4.615 0 3.077 0.769 5.385 ...
## $ ef_trade_movement_visit : num [1:1458] 8.297 1.106 0.111 7.965 10 ...
## $ ef_trade_movement : num [1:1458] 6.41 1.59 2.04 4.7 6.83 ...
## $ ef_trade : num [1:1458] 8.21 4.13 5.26 3.98 8.14 ...
## [list output truncated]
## - attr(*, "spec")=
## .. cols(
## .. year = col_double(),
## .. ISO_code = col_character(),
## .. countries = col_character(),
## .. region = col_character(),
## .. pf_rol_procedural = col_double(),
## .. pf_rol_civil = col_double(),
## .. pf_rol_criminal = col_double(),
## .. pf_rol = col_double(),
## .. pf_ss_homicide = col_double(),
## .. pf_ss_disappearances_disap = col_double(),
## .. pf_ss_disappearances_violent = col_double(),
## .. pf_ss_disappearances_organized = col_double(),
## .. pf_ss_disappearances_fatalities = col_double(),
## .. pf_ss_disappearances_injuries = col_double(),
## .. pf_ss_disappearances = col_double(),
## .. pf_ss_women_fgm = col_double(),
## .. pf_ss_women_missing = col_double(),
## .. pf_ss_women_inheritance_widows = col_double(),
## .. pf_ss_women_inheritance_daughters = col_double(),
## .. pf_ss_women_inheritance = col_double(),
## .. pf_ss_women = col_double(),
## .. pf_ss = col_double(),
## .. pf_movement_domestic = col_double(),
## .. pf_movement_foreign = col_double(),
## .. pf_movement_women = col_double(),
## .. pf_movement = col_double(),
## .. pf_religion_estop_establish = col_double(),
## .. pf_religion_estop_operate = col_double(),
## .. pf_religion_estop = col_double(),
## .. pf_religion_harassment = col_double(),
## .. pf_religion_restrictions = col_double(),
## .. pf_religion = col_double(),
## .. pf_association_association = col_double(),
## .. pf_association_assembly = col_double(),
## .. pf_association_political_establish = col_double(),
## .. pf_association_political_operate = col_double(),
## .. pf_association_political = col_double(),
## .. pf_association_prof_establish = col_double(),
## .. pf_association_prof_operate = col_double(),
## .. pf_association_prof = col_double(),
## .. pf_association_sport_establish = col_double(),
## .. pf_association_sport_operate = col_double(),
## .. pf_association_sport = col_double(),
## .. pf_association = col_double(),
## .. pf_expression_killed = col_double(),
## .. pf_expression_jailed = col_double(),
## .. pf_expression_influence = col_double(),
## .. pf_expression_control = col_double(),
## .. pf_expression_cable = col_double(),
## .. pf_expression_newspapers = col_double(),
## .. pf_expression_internet = col_double(),
## .. pf_expression = col_double(),
## .. pf_identity_legal = col_double(),
## .. pf_identity_parental_marriage = col_double(),
## .. pf_identity_parental_divorce = col_double(),
## .. pf_identity_parental = col_double(),
## .. pf_identity_sex_male = col_double(),
## .. pf_identity_sex_female = col_double(),
## .. pf_identity_sex = col_double(),
## .. pf_identity_divorce = col_double(),
## .. pf_identity = col_double(),
## .. pf_score = col_double(),
## .. pf_rank = col_double(),
## .. ef_government_consumption = col_double(),
## .. ef_government_transfers = col_double(),
## .. ef_government_enterprises = col_double(),
## .. ef_government_tax_income = col_double(),
## .. ef_government_tax_payroll = col_double(),
## .. ef_government_tax = col_double(),
## .. ef_government = col_double(),
## .. ef_legal_judicial = col_double(),
## .. ef_legal_courts = col_double(),
## .. ef_legal_protection = col_double(),
## .. ef_legal_military = col_double(),
## .. ef_legal_integrity = col_double(),
## .. ef_legal_enforcement = col_double(),
## .. ef_legal_restrictions = col_double(),
## .. ef_legal_police = col_double(),
## .. ef_legal_crime = col_double(),
## .. ef_legal_gender = col_double(),
## .. ef_legal = col_double(),
## .. ef_money_growth = col_double(),
## .. ef_money_sd = col_double(),
## .. ef_money_inflation = col_double(),
## .. ef_money_currency = col_double(),
## .. ef_money = col_double(),
## .. ef_trade_tariffs_revenue = col_double(),
## .. ef_trade_tariffs_mean = col_double(),
## .. ef_trade_tariffs_sd = col_double(),
## .. ef_trade_tariffs = col_double(),
## .. ef_trade_regulatory_nontariff = col_double(),
## .. ef_trade_regulatory_compliance = col_double(),
## .. ef_trade_regulatory = col_double(),
## .. ef_trade_black = col_double(),
## .. ef_trade_movement_foreign = col_double(),
## .. ef_trade_movement_capital = col_double(),
## .. ef_trade_movement_visit = col_double(),
## .. ef_trade_movement = col_double(),
## .. ef_trade = col_double(),
## .. ef_regulation_credit_ownership = col_double(),
## .. ef_regulation_credit_private = col_double(),
## .. ef_regulation_credit_interest = col_double(),
## .. ef_regulation_credit = col_double(),
## .. ef_regulation_labor_minwage = col_double(),
## .. ef_regulation_labor_firing = col_double(),
## .. ef_regulation_labor_bargain = col_double(),
## .. ef_regulation_labor_hours = col_double(),
## .. ef_regulation_labor_dismissal = col_double(),
## .. ef_regulation_labor_conscription = col_double(),
## .. ef_regulation_labor = col_double(),
## .. ef_regulation_business_adm = col_double(),
## .. ef_regulation_business_bureaucracy = col_double(),
## .. ef_regulation_business_start = col_double(),
## .. ef_regulation_business_bribes = col_double(),
## .. ef_regulation_business_licensing = col_double(),
## .. ef_regulation_business_compliance = col_double(),
## .. ef_regulation_business = col_double(),
## .. ef_regulation = col_double(),
## .. ef_score = col_double(),
## .. ef_rank = col_double(),
## .. hf_score = col_double(),
## .. hf_rank = col_double(),
## .. hf_quartile = col_double()
## .. )
## NULL
age_levels <- c("5-14", "15-24", "25-34", "35-54", "55-74", "75+")
suic_fmt <- suicides %>%
mutate(country = factor(country),
year = year,
sex = factor(sex),
age = factor(str_replace(age, " years", ""), levels = age_levels),
suicides_p100k = `suicides/100k pop`,
gdp_per_capita = `gdp_per_capita ($)`) %>%
select(country, year, sex, age, suicides_no, population, suicides_p100k, gdp_per_capita)
print(summary(suic_fmt))## country year sex age suicides_no
## Austria : 382 Min. :1985 female:13910 5-14 :4610 Min. : 0
## Iceland : 382 1st Qu.:1995 male :13910 15-24:4642 1st Qu.: 3
## Mauritius : 382 Median :2002 25-34:4642 Median : 25
## Netherlands: 382 Mean :2001 35-54:4642 Mean : 243
## Argentina : 372 3rd Qu.:2008 55-74:4642 3rd Qu.: 131
## Belgium : 372 Max. :2016 75+ :4642 Max. :22338
## (Other) :25548
## population suicides_p100k gdp_per_capita
## Min. : 278 Min. : 0.00 Min. : 251
## 1st Qu.: 97498 1st Qu.: 0.92 1st Qu.: 3447
## Median : 430150 Median : 5.99 Median : 9372
## Mean : 1844794 Mean : 12.82 Mean : 16866
## 3rd Qu.: 1486143 3rd Qu.: 16.62 3rd Qu.: 24874
## Max. :43805214 Max. :224.97 Max. :126352
##
Nothing out of the ordinary here. It seems like we read in the whole file and do not need to skip any header or footer miscellaneous data.
## # A tibble: 6 x 8
## country year sex age suicides_no population suicides_p100k gdp_per_capita
## <fct> <dbl> <fct> <fct> <dbl> <dbl> <dbl> <dbl>
## 1 Albania 1987 male 15-24 21 312900 6.71 796
## 2 Albania 1987 male 35-54 16 308000 5.19 796
## 3 Albania 1987 fema… 15-24 14 289700 4.83 796
## 4 Albania 1987 male 75+ 1 21800 4.59 796
## 5 Albania 1987 male 25-34 9 274300 3.28 796
## 6 Albania 1987 fema… 75+ 1 35600 2.81 796
## # A tibble: 6 x 8
## country year sex age suicides_no population suicides_p100k gdp_per_capita
## <fct> <dbl> <fct> <fct> <dbl> <dbl> <dbl> <dbl>
## 1 Uzbeki… 2014 fema… 25-34 162 2735238 5.92 2309
## 2 Uzbeki… 2014 fema… 35-54 107 3620833 2.96 2309
## 3 Uzbeki… 2014 fema… 75+ 9 348465 2.58 2309
## 4 Uzbeki… 2014 male 5-14 60 2762158 2.17 2309
## 5 Uzbeki… 2014 fema… 5-14 44 2631600 1.67 2309
## 6 Uzbeki… 2014 fema… 55-74 21 1438935 1.46 2309
Sorting by suicide counts descending tells us that Russian men age 35-54 had the highest suicide raw counts around the 1990s to early 2000s, but this is not scaled by population yet. If we instead look at suicides per 100k persons, will the same trend appear?
## # A tibble: 1,467 x 8
## country year sex age suicides_no population suicides_p100k
## <fct> <dbl> <fct> <fct> <dbl> <dbl> <dbl>
## 1 Russian Federation 1994 male 35-54 22338 19044200 117.
## 2 Russian Federation 1995 male 35-54 21706 19249600 113.
## 3 Russian Federation 2001 male 35-54 21262 21476420 99
## 4 Russian Federation 2000 male 35-54 21063 21378098 98.5
## 5 Russian Federation 1999 male 35-54 20705 21016400 98.5
## 6 Russian Federation 1996 male 35-54 20562 19507100 105.
## 7 Russian Federation 1993 male 35-54 20256 18908000 107.
## 8 Russian Federation 2002 male 35-54 20119 21320535 94.4
## 9 Russian Federation 1997 male 35-54 18973 19913400 95.3
## 10 Russian Federation 2003 male 35-54 18681 21007346 88.9
## # … with 1,457 more rows, and 1 more variable: gdp_per_capita <dbl>
Russian men are no longer at the top of list, so it may have been due to their large population that so many suicides occurred. In both of these lists I see only male persons that are older as well, so maybe sex or age plays a factor here.
## # A tibble: 27,820 x 8
## country year sex age suicides_no population suicides_p100k
## <fct> <dbl> <fct> <fct> <dbl> <dbl> <dbl>
## 1 Aruba 1995 male 75+ 2 889 225.
## 2 Seychelles 2006 male 75+ 2 976 205.
## 3 Suriname 2012 male 75+ 10 5346 187.
## 4 Republic of Korea 2011 male 75+ 1276 688365 185.
## 5 Republic of Korea 2010 male 75+ 1152 631853 182.
## 6 Hungary 1992 male 75+ 317 178482 178.
## 7 Hungary 1993 male 75+ 300 168944 178.
## 8 Hungary 1991 male 75+ 333 188235 177.
## 9 Republic of Korea 2005 male 75+ 780 442349 176.
## 10 Hungary 1994 male 75+ 292 165660 176.
## # … with 27,810 more rows, and 1 more variable: gdp_per_capita <dbl>
# We can also look at the quantile breakdown for suicides per 100k persons:
quantile(suic_fmt$suicides_p100k, probs = seq(0, 1, 1/10))## 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
## 0.00 0.00 0.41 1.60 3.54 5.99 9.09 13.56 20.53 33.29 224.97
# A boxplot can show us visually that the rates are pretty low except for some high outliers
boxplot(suic_fmt$suicides_p100k)Does sex or age contribute to historic suicide rates? Yes, it does seem like suicides are more common among men than women and elderly vs young folks, though this plot contains 30 years of data for over 100 countries.
ggplot(suic_fmt) +
geom_jitter(aes(x = sex, y = suicides_p100k, color = sex),
alpha = 0.2) +
facet_grid( ~ age)I first tried a regular histogram for the variable suicide_no, but there is such a pronounced right skew that applying a log to the x axis made sense. I believe population, suicides per 100k, and gdp per capita might have a similar problem in viewing their distributions with no transformations applied.
I created a log histogram and density plot function to help in making these 4 plots. The get() function can give ggplot the correct column name from an input “string” column name. If I was using Python, I would have created a dictionary and looped over it to get the column and axis labels, but R makes this process harder.
make_hist <- function(xlab, col) {
ggplot(suic_fmt) +
geom_histogram(aes(x = log(get(col)), y = ..density..)) +
geom_density(aes(x = log(get(col)))) +
labs(x = xlab, y = "Frequency")
}
h1 <- make_hist(xlab = "log(Suicides)", col = "suicides_no")
h2 <- make_hist(xlab = "log(Population)", col = "population")
h3 <- make_hist(xlab = "log(Suicides_Per100k)", col = "suicides_p100k")
h4 <- make_hist(xlab = "log(GDP_Per_Capita)", col = "gdp_per_capita")
grid.arrange(h1, h2, h3, h4, ncol = 2)Lastly, I would like to take a look at the year variable to see if there is any time-series trends at play.
suic_totals <- suic_fmt %>%
select(year, country, suicides_no, population) %>%
group_by(year, country) %>%
summarize(total_suicides = sum(suicides_no),
total_pop = sum(population),
total_suicides_p100k = total_suicides / total_pop * 100000)
# We are missing data from some years for some countries
# Show table of year, country, suicide rates
# pivot_longer(suic_totals, year,
ggplotly(ggplot(suic_totals) +
geom_line(aes(x = year, y = total_suicides_p100k, color = country, group = country),
alpha = 0.3, show.legend = FALSE))